import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  // 登录
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
// 首页
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页', icon: 'dashboard' }
    }]
  },
 
  
  // 管理员
  {
    path: '/admin',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'admin',
        component: () => import('@/views/admin/index'),
        meta: { title: '管理员信息管理', icon: 'el-icon-user-solid' }
      }
    ]
  },
   
  // 新闻
  {
    path: '/news',
    component: Layout,
    children: [
      {
        path: 'index',
        name:'News',
        component: () => import('@/views/news/index'),
        meta: { title: '新闻资讯管理', icon: 'el-icon-reading' }
      }
    ]
  },
  // 类别
  {
    path: '/leibie',
    component: Layout,
    children: [
      {
        path: 'index',
        name:'Leibie',
        component: () => import('@/views/leibie/index'),
        meta: { title: '手机类别管理', icon: 'el-icon-warning-outline' }
      }
    ]
  },
  // 点评
  {
    path: '/dianping',
    component: Layout,
    children: [
      {
        path: 'index',
        name:'dianping',
        component: () => import('@/views/dianping/index'),
        meta: { title: '用户点评管理', icon: 'el-icon-chat-line-round' }
      }
    ]
  },
  // 产品
  {
    path: '/product',
    component: Layout,
    children: [
      {
        path: 'index',
        name:'product',
        component: () => import('@/views/product/index'),
        meta: { title: ' 手机产品管理', icon: 'el-icon-goods' }
      },
    ],
    
  },
  // 产品编辑
  {
    path: '/product_',
    component: Layout,
    children: [
      {
        path: 'product_edit',
        name:'product_',
        component: () => import('@/views/product_/product_edit'),
      },
    ]
  },
  // 产品添加
  {
    path: '/product_add',
    component: Layout,
    children: [
      {
        path: 'product_add',
        name:'product_add',
        component: () => import('@/views/product_add/product_add'),
      }
    ]
  },
   
  
 

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
